package com.nuc.impl2;

/**
 * Time    : 2023/3/28 21:35
 * Author  : 王摇摆
 * FileName: Monster.java
 * Software: IntelliJ IDEA 2020.2.2
 * Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
 */

public class Monster {
    private String name;
    private int healthPoint;

    public Monster() {
    }

    public Monster(String name, int healthPoint) {
        this.name = name;
        this.healthPoint = healthPoint;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getHealthPoint() {
        return healthPoint;
    }

    public void setHealthPoint(int healthPoint) {
        this.healthPoint = healthPoint;
    }

    public void handle(String weaponName, int damage) {
        if (this.healthPoint <= 0) {
            System.out.println("怪物" + this.name + "已经死亡，无法继续攻击！");
            return;
        } else
            this.healthPoint = this.healthPoint - damage;

        if (this.healthPoint<=0)
            System.out.println("剑客使用"+weaponName+"攻击成功！怪物"+this.name+"已经死亡。");
        else
            System.out.println("剑客使用"+weaponName+"攻击成功！怪物"+this.name+"血量减少"+damage+"点，还剩"+this.healthPoint+"点血量");
    }
}
